#include "../tools.h"

class Solution {
public:
    int maxIceCream(vector<int>& costs, int coins) {
        sort(costs.begin(), costs.end());

        int res = 0;
        for(int i = 0; i < costs.size(); ++i){
            if(coins >= costs[i]){
                coins -= costs[i];
                ++res;
            }
            else
                return res;

        }

        return res;

    }
};


int main(int argc, char const *argv[])
{
    
    vector<int> costs = {1,6,3,1,2,5};
    int coins = 20;

    Solution s;
    cout << s.maxIceCream(costs, coins);

    return 0;
}
